function CustomToString(target: Function) {
    target.prototype.toString = function () {
        return JSON.stringify(this)
    }
    // 不允许随便在原型上修改属性
    Object.seal(target.prototype)
}

@CustomToString
class Person {
    constructor(public name: string, public age: number) {}
}

const p1 = new Person('小米', 20)
interface Person {
    x: number
}
// Person.prototype.x = 99
console.log(p1.toString())
console.log(p1.x)


function NewHouse(target:Function) {
    return class {
        test() {
            console.log('200')
            console.log('300')
        }
    }
}

@NewHouse
class House {
    test() {
        console.log('100')
    }
}

console.log(House)


/**
 * @new 表示可以用new进行操作
 * @..args 表示接收任意数量的参数
 * @any [] 表示参数可以是任意类型的值
 * @{} 表示返回一个对象 非null undefined
 */
// type Constructore = new(...args:any[]) => {}

type Constructore = {
    new(...args:any[]): {}
    wife: string
}

type Constructores = {
    new(...args:any[]): {}
}

function tests(fn:Constructore) {

}

function Logtime<T extends Constructores>(target: T) {
     return class extends target {
        createTime:Date
        constructor(...args:any[]) {
            super(...args)
            this.createTime = new Date()
        }
     }
}
@Logtime
class Persons {
    static wife: string
}
tests(Persons)